package servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Hashtable;
import java.util.List;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import sessions.AbilitaManagerRemote;
import staticHtml.PaginaStatica;
import entities.Utente;

public class LogoutServlet extends HttpServlet{

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		logout(request, response);
	}
	
	private void logout(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

		//if(request.getSession().getAttribute("utente")!=null)
		//{
			request.getSession().removeAttribute("utente");
		//	request.getSession().invalidate();
		//}
		//if(request.getSession().getAttribute("amministratore")!=null)
		//{
			request.getSession().removeAttribute("amministratore");
			request.getSession().invalidate();
		
		//}
		
			PrintWriter out = response.getWriter();
			out.println(PaginaStatica.top());
			out.println("Logout effettuato<br><a href='index.html'>Home</a>");
			out.println(PaginaStatica.bottom());

		
	}
}
